package com.rjxy.plansystemmanagement.mapper;

import com.rjxy.plansystemmanagement.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {
    /**
     * 查询全部用户
     * @return
     */
    @Select("select * from user")
    List<User> list();

    /**
     * 根据ID删除用户
     * @param id
     */
    @Delete("delete from user where id = #{id}")
    void deleteById(Integer id);

    /**
     * 增加用户
     * @param user
     */
    @Insert("insert into user(UserName,Password,Name,Sex,SfID,Tel) " +
            "VALUES (#{UserName},#{Password},#{Name},#{Sex},#{SfID},#{Tel})")
    void addUser(User user);

    /**
     * 根据id查询用户
     * @param id
     * @return
     */
    @Select("select * from user where id = #{id}")
    User getUserById(Integer id);

    void updateUser(User user);
    @Select("select * from user where username = #{UserName} and password = #{Password}")
    User getUserByUserNameAndPassword(User user);

    @Select("select * from user where username = #{UserName}")
    User getUserByUserName(String UserName);
}
